Imports System.IO
Public Class FormFileWatcher
    Private WithEvents Watcher As New FileSystemWatcher("C:\")
    Private Sub btnTracing_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTracing.Click
        Watcher.Filter = "*.*"
        Watcher.IncludeSubdirectories = True
        Watcher.EnableRaisingEvents = True
    End Sub

    Private Sub tnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tnStop.Click
        Watcher.EnableRaisingEvents = False
    End Sub

    Private Sub Watcher_Changed(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles Watcher.Changed
        Dim DateAndTime As DateTime = DateTime.Now
        CheckForIllegalCrossThreadCalls = False
        TextBox1.AppendText(e.FullPath & " " _
           & e.ChangeType() & " " & DateAndTime & vbCrLf)
    End Sub
End Class
